import CryptoJS from "@/common/CryptoJS.min.js";
// 解密方法
export function decrypt(word, key) {
	key = CryptoJS.enc.Utf8.parse(key);
	var data = CryptoJS.AES.decrypt(word, key, {
		iv: key,
		padding: CryptoJS.pad.Pkcs7
	}).toString(CryptoJS.enc.Utf8);
	return data;
}


// 获取url参数
export function getQueryVariable(paraName) {
	var url = document.location.toString();
	var arrObj = url.split("?");
	if (arrObj.length > 1) {
		var arrPara = arrObj[1].split("&");
		var arr;
		for (var i = 0; i < arrPara.length; i++) {
			arr = arrPara[i].split("=");
			if (arr != null && arr[0] == paraName) {
				return arr[1];
			}
		}
		return "";
	} else {
		return "";
	}
}

// 银行卡号脱敏
export function desensitizeCardNumber(cardNumber) {
	console.log(cardNumber)
	const length = cardNumber.length;
	if (length <= 4) return cardNumber;
	const firstFour = cardNumber.substring(0, 4);
	const lastFour = cardNumber.substring(length - 4);
	const middle = "*".repeat(length - 8);
	return firstFour +' '+ middle +' '+ lastFour;
}